package com.ybkj.daijia.serverUtils;

import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import org.springframework.stereotype.Component;

@Component
public class DataUtils {

    private final String[] str = new String[]{"微信", "支付宝", "银联"};

    private final String[] str1 = new String[]{"个人", "企业"};

    public static void main(String[] args) {
        System.out.println(new DataUtils().getLatLng("成都市").toString());
    }

    public int getRandomInt(int i) {
        return new Random().nextInt(i);
    }

    public Double getRandomDouble() {
        return new Random().nextDouble();
    }

    public String getRandomString() {
        String str = "QWERTYUIOPASDFGHJKLZXCVBNM1234567890012345678901234567890123456789";
        return String.valueOf(str.charAt(getRandomInt(56)));
    }

    public String getIp() {
        String[] ips = new String[]{"180.118.151.177", "118.180.153.95", "27.10.98.95",
            "223.10.98.95", "171.121.124.132", "123.182.99.226", "60.16.107.5", "125.124.206.27",
            "119.125.145.163", "182.90.104.172", "218.5.247.151", "121.235.177.184", "42.157.77.5",
            "123.121.24.96", "183.67.162.229", "219.139.51.120", "139.170.107.104", "116.246.8.1",
            "36.4.76.60", "112.123.232.58", "49.72.189.29", "61.153.178.40", "60.162.90.78",
            "153.118.182.239", "113.233.114.201", "183.133.102.112", "211.154.147.181",
            "113.1.24.160", "119.143.222.9", "116.29.171.234", "222.180.237.232", "118.225.24.188",
            "119.128.90.143", "116.55.100.146", "218.24.174.166", "139.198.78.161",
            "220.183.59.150", "124.165.102.152", "106.58.153.86", "119.45.152.71", "117.77.85.58",
            "106.43.134.206", "118.75.106.217", "116.225.121.46", "115.239.187.253",
            "202.106.147.29", "27.217.169.249", "27.153.196.236", "110.245.4.132", "123.128.164.59",
            "111.124.107.124", "183.38.33.25", "61.179.235.218", "182.107.25.92", "114.89.188.14",
            "124.108.10.80", "218.8.48.229", "58.249.93.119", "218.58.190.126", "113.103.235.103",
            "1.8.20.172", "222.178.241.95", "121.224.95.244", "106.40.231.191", "116.191.247.184",
            "27.185.101.140", "106.42.240.102", "14.208.106.48", "60.11.139.176", "182.89.218.14",
            "27.198.179.165", "175.170.103.90", "106.37.241.223", "183.21.85.38", "123.156.66.7",
            "117.85.89.172", "42.183.155.206", "124.128.9.45", "111.176.104.44", "153.37.70.126",
            "106.28.54.245", "101.20.113.254", "119.145.11.150", "222.178.122.127",
            "110.187.170.58", "220.166.45.243", "175.164.250.76", "222.70.143.73", "115.170.8.232",
            "61.178.28.97", "125.94.132.190", "223.201.36.87", "60.165.26.39", "60.167.203.124",
            "183.44.246.102", "1.85.218.146", "49.70.97.214", "101.71.33.132", "202.105.198.101",
            "222.189.117.87", "223.15.36.91", "58.40.176.24", "114.102.195.226", "61.187.96.2",
            "125.115.169.217", "36.249.163.30", "182.54.25.7", "101.91.182.50", "116.5.236.249",
            "119.50.2.164", "1.70.185.254", "101.204.165.225", "119.115.77.8", "182.240.123.21",
            "106.19.129.206", "116.128.14.83", "42.5.23.178", "221.220.214.202", "42.89.94.186",
            "202.100.231.150", "113.16.250.125", "183.70.180.169", "116.158.220.117",
            "27.9.205.167", "59.61.90.15", "120.35.242.234", "106.89.160.40", "58.60.57.47",
            "118.80.157.131", "39.86.109.158", "222.161.89.251", "113.228.249.180", "114.89.86.78",
            "118.251.247.210", "116.133.23.107", "115.229.72.13", "218.93.160.8", "123.159.108.102",
            "223.214.70.66", "116.173.97.99", "223.146.216.135", "111.224.228.97", "183.10.37.16",
            "101.16.246.253", "114.249.120.142", "59.42.97.159", "14.20.212.234", "116.139.67.198",
            "219.72.175.5", "112.83.67.216", "182.36.100.185", "58.208.3.216", "112.73.83.82",
            "125.118.131.0", "112.239.146.233", "222.180.200.121", "61.135.145.243",
            "182.142.56.50", "113.104.205.53", "182.103.228.90", "180.130.210.198", "222.93.52.17",
            "14.23.252.91", "113.0.177.158", "110.90.236.158", "116.207.236.109", "114.105.240.228",
            "222.80.232.164", "27.153.123.199", "113.62.51.123", "61.132.243.153", "114.95.187.254",
            "1.50.249.206", "125.110.14.40", "121.10.205.209", "223.198.136.237", "221.6.247.152",
            "1.62.253.119", "60.31.2.75", "116.135.204.107", "119.136.253.99", "116.54.59.112",
            "124.229.152.152", "124.230.153.178", "106.43.194.99", "175.22.84.73", "39.81.152.188",
            "110.250.49.186", "113.2.143.100", "123.159.3.142", "125.47.94.132", "113.125.145.116",
            "123.113.66.41", "119.39.43.38", "222.180.225.66", "110.152.19.115", "150.115.17.126",
            "222.171.34.17", "113.122.116.31", "183.59.88.67", "118.251.29.117", "118.75.193.192",
            "150.139.102.106", "36.113.198.196", "106.4.71.103", "117.29.231.17", "14.134.123.182",
            "116.95.156.246", "60.173.253.93", "223.241.39.54", "183.57.185.199", "58.55.147.175",
            "202.108.121.112", "120.82.249.126", "220.189.149.234", "14.220.208.146",
            "61.165.67.77", "222.92.111.42", "175.170.227.59", "116.175.172.217", "223.167.29.130",
            "60.186.115.49", "36.120.244.60", "124.95.213.52", "113.3.52.160", "110.152.123.8",
            "49.84.20.15", "116.157.76.172", "61.131.94.109", "220.173.38.215", "219.128.246.122",
            "171.114.97.99", "182.54.109.53", "183.64.202.127", "27.223.54.232", "120.13.7.47",
            "119.50.55.232", "106.19.59.186", "125.43.131.103", "120.131.227.187", "61.161.150.17",
            "124.236.148.48", "182.117.110.207", "123.13.209.167", "221.216.126.169",
            "183.150.111.88", "14.223.213.75", "171.95.156.156", "220.252.36.26", "27.18.213.87",
            "113.209.207.164", "14.108.18.238", "42.185.72.197", "61.139.34.116", "49.86.134.235",
            "112.238.139.81", "171.94.243.229", "42.81.73.78", "122.243.247.155", "119.89.4.63",
            "42.122.24.196", "111.228.50.136", "123.115.165.82", "27.211.75.10", "113.235.31.179",
            "114.238.62.56", "118.115.166.72", "122.51.136.119", "183.154.127.55", "123.4.82.182",
            "27.217.184.8", "59.173.138.46", "120.10.171.146", "125.65.132.153", "219.137.228.114",
            "61.128.36.249", "101.69.26.240", "114.251.157.129", "123.183.156.2", "122.243.27.220",
            "171.114.70.207", "119.44.89.18", "59.48.4.21", "210.13.37.103", "223.214.218.137",
            "27.29.133.15", "116.232.5.68", "123.112.211.250", "175.12.242.240", "113.231.53.250",
            "223.13.164.168", "171.223.7.143", "111.165.242.157", "58.210.230.72",
            "110.184.135.209", "103.29.19.245", "61.132.128.135", "106.7.192.161", "124.238.200.6",
            "124.231.30.44", "180.107.213.92", "116.28.226.171", "180.101.9.185", "119.40.174.242",
            "118.180.180.136", "112.236.236.15", "60.217.160.225", "183.164.31.178",
            "123.152.237.214", "36.118.227.92", "218.56.116.216", "106.39.148.201", "117.92.98.163",
            "60.169.239.156", "118.123.230.148", "1.10.67.29", "110.230.237.165", "119.131.107.198",
            "27.217.37.225", "123.184.87.80", "182.118.32.68", "220.196.212.224", "113.74.128.179",
            "1.56.64.228", "115.171.52.155", "120.44.169.182", "120.83.51.23", "203.93.72.212",
            "139.215.174.98", "58.41.27.22", "203.34.106.39", "171.127.72.161", "39.74.26.130",
            "113.204.88.216", "223.151.112.98", "218.94.121.112", "112.111.77.69", "42.49.33.77",
            "183.128.28.234", "1.62.72.247", "113.76.37.134", "39.70.140.41", "113.200.133.40",
            "61.160.104.88", "122.188.135.207", "218.11.133.24", "42.229.211.141", "222.90.70.152",
            "114.243.183.76", "117.48.161.215", "220.160.216.22", "115.200.169.180",
            "27.210.247.242", "113.122.17.125", "118.116.108.128", "183.144.91.109",
            "183.27.168.158", "36.124.231.109", "110.156.112.227", "183.26.120.17", "110.19.77.76",
            "49.91.43.233", "221.204.192.199", "60.0.198.199", "139.212.49.147", "171.83.203.228",
            "125.171.84.18", "119.37.208.187", "58.41.33.245", "106.89.155.182", "222.170.189.27",
            "220.172.127.54", "14.29.19.208", "106.122.190.146", "123.246.143.36", "111.202.116.93",
            "171.43.173.100", "171.220.150.166", "222.189.187.107", "221.220.145.35",
            "220.164.71.212", "121.101.223.177", "118.191.54.4", "121.18.237.51", "106.56.245.232",
            "42.81.195.12", "182.142.131.34", "61.243.173.193", "36.97.45.8", "59.62.56.182",
            "116.3.44.62", "222.190.252.0", "219.154.2.134", "27.37.11.33", "27.13.168.156",
            "59.42.72.180", "27.210.156.151", "116.77.71.44", "124.166.78.24", "183.69.55.9",
            "124.129.36.239", "61.48.215.155", "222.79.15.20", "59.38.19.213", "59.172.115.139",
            "218.17.39.95", "60.28.55.236", "182.44.174.23", "222.213.70.101", "27.17.203.138",
            "14.107.48.244", "115.201.232.148", "113.239.12.77", "27.210.232.143", "114.226.34.169",
            "113.200.173.44", "183.24.36.142", "180.223.33.206", "117.44.238.245",
            "101.204.249.131", "218.5.152.11", "114.221.206.13"};
        return ips[new Random().nextInt(ips.length - 1)];
    }

    public String getPort() {
        StringBuilder port = new StringBuilder();
        int len = getRandomInt(1) + 4;
        for (int i = 0; i < len; i++) {
            port.append(getRandomInt(9));
        }
        return port.toString();
    }

    public String getMAC() {
        StringBuilder mac = new StringBuilder();
        for (int i = 0; i < 6; i++) {
            mac.append(getRandomString());
            mac.append(getRandomString());
            if (i != 5) {
                mac.append(":");
            }
        }
        return mac.toString();
    }

    public String getIMxI() {
        StringBuilder IMSI = new StringBuilder();
        for (int i = 0; i < 15; i++) {
            IMSI.append(getRandomInt(9));
        }
        return IMSI.toString();
    }

    public String getBindingPayAccountType(int type) {
        return str1[type];
    }

    public Double getRandomSize(Double min, Double max) {
        DecimalFormat df = new DecimalFormat("0.000000");
        return Double.valueOf(df.format(min + (max - min) * getRandomDouble()));
    }

    public Map<String, Double> getLatLng(String cityName) {
        HashMap<String, Double> map = new HashMap<>();
        if (cityName.equals("遵义市")) {
            Double lat1 = 27.802639;
            Double lat2 = 27.505835;
            Double lng1 = 106.770629;
            Double lng2 = 107.137298;
            map.put("lat", getRandomSize(lat1, lat2));
            map.put("lng", getRandomSize(lng1, lng2));
            return map;
        }
        if (cityName.equals("成都市")) {
            Double lat1 = 31.055286;
            Double lat2 = 30.270928;
            Double lng1 = 103.499450;
            Double lng2 = 104.632415;
            map.put("lat", getRandomSize(lat1, lat2));
            map.put("lng", getRandomSize(lng1, lng2));
            return map;
        }
        return map;
    }

    public String getCooperationAccountType() {
        return str[getRandomInt(1)];
    }
}
